package com.ds.esd.bpm.custom.plugins.right;

import com.alibaba.fastjson.annotation.JSONField;
import com.ds.bpm.client.ActivityDef;
import com.ds.bpm.client.RouteToType;
import com.ds.bpm.engine.WorkflowClientService;
import com.ds.esd.custom.form.enums.CustomFormMenu;
import com.ds.esd.custom.nav.annotation.TabsAnnotation;
import com.ds.esd.custom.nav.tab.annotation.TabItemAnnotation;
import com.ds.esd.tool.ui.component.item.TabListItem;
import com.ds.jds.core.esb.EsbUtil;
import com.ds.web.annotation.Pid;


@TabsAnnotation(bottombarMenu = {CustomFormMenu.SubmitForm, CustomFormMenu.Close}, autoReload = false)
public class NextActivityTree extends TabListItem {

    @Pid
    public String topOrgId;
    @Pid
    public RouteToType action;
    @Pid
    public String activityInstId;
    @Pid
    public String nextActivityDefId;
    @Pid
    public String performGroup;

    @TabItemAnnotation(bindService = NextActivityTreeService.class, caption = "选择办理人")
    public NextActivityTree(ActivityDef activityDef, String activityInstId, RouteToType action, String topOrgId) {
        super(activityDef.getActivityDefId(), activityDef.getName());
        this.tag = activityDef.getActivityDefId();
        this.topOrgId = topOrgId;
        this.action = action;
        this.activityInstId = activityInstId;
        this.nextActivityDefId = activityDef.getActivityDefId();

    }


    @TabItemAnnotation(customItems = PerformGroupItem.class, caption = "办理人组")
    public NextActivityTree(PerformGroupItem performGroupItem, String activityInstId, RouteToType action, String topOrgId, String nextActivityDefId) {
        super(performGroupItem.getType(), performGroupItem.getName(), performGroupItem.getImageClass());
        this.setName(performGroupItem.getType());
        this.setDesc(performGroupItem.getName());
        this.topOrgId = topOrgId;
        this.action = action;
        this.activityInstId = activityInstId;
        this.nextActivityDefId = nextActivityDefId;
    }

    public String getTopOrgId() {
        return topOrgId;
    }

    public void setTopOrgId(String topOrgId) {
        this.topOrgId = topOrgId;
    }

    public RouteToType getAction() {
        return action;
    }

    public void setAction(RouteToType action) {
        this.action = action;
    }

    public String getActivityInstId() {
        return activityInstId;
    }

    public void setActivityInstId(String activityInstId) {
        this.activityInstId = activityInstId;
    }

    public String getNextActivityDefId() {
        return nextActivityDefId;
    }

    public void setNextActivityDefId(String nextActivityDefId) {
        this.nextActivityDefId = nextActivityDefId;
    }

    public String getPerformGroup() {
        return performGroup;
    }

    public void setPerformGroup(String performGroup) {
        this.performGroup = performGroup;
    }

    /**
     * @return
     */
    @JSONField(serialize = false)
    private WorkflowClientService getClient() {
        WorkflowClientService client = ((WorkflowClientService) EsbUtil.parExpression("$BPMC"));
        return client;
    }
}
